// 通用键名
const INFO_KEY = 'zw_shopping_info'
export const getInfo = () => {
  const defaultObj = { token: '', userId: '' }
  const res = localStorage.getItem(INFO_KEY)
  return res ? JSON.parse(res) : defaultObj
}
// 设置个人信息
export const setInfo = (obj) => {
  localStorage.setItem(INFO_KEY, JSON.stringify(obj))
}
export const removeInfo = () => {
  localStorage.removeItem(INFO_KEY)
}

// 搜索记录
const INFO_SEARCH = 'zw_search_info'
export const getInfoSearch = () => {
  const res = localStorage.getItem(INFO_SEARCH)
  return res ? JSON.parse(res) : []
}
export const setInfoSearch = (arr) => {
  localStorage.setItem(INFO_SEARCH, JSON.stringify(arr))
}
